package com.tosit.bmx.common.filter;


import com.tosit.bmx.domian.User;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 清除指定缓存session
 *
 * @author tsl
 * @create 2018-05-04 16:08
 **/
public class ClearSessionFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;

        Object s = req.getSession().getAttribute("s");
        Object msg = req.getSession().getAttribute("msg");
        if (s != null) {
            req.getSession().removeAttribute("s");
        }
        if (msg != null) {
            req.getSession().removeAttribute("msg");
        }

        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }

}
